<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html>
	<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta name="keywords" content="scclui框架">
	<meta name="description" content="scclui为轻量级的网站后台管理系统模版。">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<title>后台管理系统</title>
	<script type="text/javascript" src="/HouTaiGuanLiZuiZhong/recycle/Public/common/js/jquery-1.8.2.min.js"></script>
		<script type="text/javascript">
			$(function () {
//				添加分类
				$('#pushBtn').click(function () {
					var classes = $("input[name='classes']").val()
					var url = $('#hid').val();
					$.get(url,{className:classes},function(data){
						if(data){
							alert(data);
							window.location.reload()
						}else{
							alert('添加失败')
						}
					})
				})
//				删除分类
				$('.delete_class').click(function (e) {
					e.preventDefault();
					var url = $('#hid').val();
					var id = $(this).attr("href");
					$.get(url,{id:id},function(data){
						if(data){
							alert(data)
							window.location.reload()
						}else{
							alert('删除失败')
						}
					})
				})
				//修改分类
				$('.update_class').click(function (e) {
					e.preventDefault();
					var id=$(this).attr('href');
					$('body').append("<p>写下修改的名称:</p><input type='text' name='updateName'><button id='updateBtn'>修改</button>")
					$('#updateBtn').click(function () {
						var url=$("#classUrl").val();
						var updateName=$("input[name='updateName']").val();
						$.get(url,{id:id,updateName:updateName},function(data){
							if(data){
								alert(data)
								window.location.reload();
							}else{alert("未知错误")}
						})
					})
				})
			})
		</script>
	</head>

	<body>
	<!--分类-->
	<b>当前分类：</b>
	<table>
		<?php if($rs == array()): ?>当前还没有分类，您可以点击添加分类
			<tr>
		<?php else: ?>
			<?php if(is_array($rs)): $i = 0; $__LIST__ = $rs;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$data): $mod = ($i % 2 );++$i;?><td><?php echo ($data["class"]); ?></td><?php endforeach; endif; else: echo "" ;endif; ?>
			</tr><?php endif; ?>
	</table>
	<p><b>添加分类：</b></p>

		<p>
			输入分类名：
			<input type="text" name="classes">
			<input type="hidden" id="hid" value="<?php echo U('checkClass');?>">
			<button id="pushBtn">添加</button>
		</p>
		<p>
			<b>请点击要删除的分类：</b>
			<table>
				<tr>
					<?php if(is_array($rs)): $i = 0; $__LIST__ = $rs;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$data): $mod = ($i % 2 );++$i;?><td><a href="<?php echo ($data["id"]); ?>" class="delete_class" style="text-decoration: none"><?php echo ($data["class"]); ?></a></td><?php endforeach; endif; else: echo "" ;endif; ?>
				</tr>
			</table>
		</p>
		<p>
			<b>请点击要修改的分类：</b>
		<table>
			<tr>
				<?php if(is_array($rs)): $i = 0; $__LIST__ = $rs;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$data): $mod = ($i % 2 );++$i;?><td><a href="<?php echo ($data["id"]); ?>" class="update_class" style="text-decoration: none"><?php echo ($data["class"]); ?></a></td><?php endforeach; endif; else: echo "" ;endif; ?>
			</tr>
		<input type="hidden" value="<?php echo U('classUpdate');?>" id="classUrl">
		</table>
		</p>
	</body>
</html>